import {Http} from '@angular/http';
import {NgLayer, NgLayerRef} from 'ng2-layer';
import {Component,ViewContainerRef,ElementRef}  from '@angular/core';

@Component({
	templateUrl:"template/router/order.html"
})
export class OrderComp{
	status:any = ['', '待发货','已发货','确认收货','交易完成','已取消'];
	isPay:any = ['线下','线上'];
	detailId = -1;
	
	orders:any;
	//获取订单列表哦
	constructor(private http:Http, private layer:NgLayer){
		this.http.get({
			search:{
				m:"Admin",
				c:"ApiSchool",
				a:"getOrderList"
			}
		}).then((data)=>{
			this.orders = data.data;
		});
	}
	
	//发布订单
	send(order:any){
		this.http.get({
			message:"提交数据...",
			search:{
				m:"Admin",
				c:"ApiOrder",
				a:"setOrderDeliver",
				order_id:order.order_id
			}
		}).then((data)=>{
			order.status = 2;
		});
	}
	
	//取消订单
	cancel(order:any){
		this.http.get({
			message:"提交数据...",
			search:{
				m:"Admin",
				c:"ApiOrder",
				a:"operationOrder",
				order_id:order.order_id,
				"do":"cancelOrder "
			}
		}).then((data)=>{
			order.status = 5;
		});
	}
}
